﻿using System;
using UtilZ.Dotnet.Ex.Base;

namespace ConAppCore.Test
{
    internal class TestActivatorEx : Object, ITestActivatorEx
    {
        public TestActivatorEx()
        {

        }

        public TestActivatorEx(int a, int? b, object c)
        {

        }

        public void SetValue(int value)
        {

        }


        public static void Test()
        {
            var xx1 = Nullable.GetUnderlyingType(typeof(int?));
            var xx2 = Nullable.GetUnderlyingType(typeof(int));
            var xx3 = Nullable.GetUnderlyingType(typeof(Program));
            //var xx4 = Nullable.GetUnderlyingType(typeof(Program?));


            Type type = typeof(TestActivatorEx);
            var obj1 = ActivatorEx.CreateInstance<TestActivatorEx>(type);
            var obj2 = ActivatorEx.CreateInstance<TestActivatorEx>(type, new object[] { });
            var obj3 = ActivatorEx.CreateInstance<TestActivatorEx>(type, new object[] { 123, null, null });
            //var obj4 = ActivatorEx.CreateInstance<TestActivatorEx>(type, new object[] { null, 123, null });
            var obj5 = ActivatorEx.CreateInstance<TestActivatorEx>(type, new object[] { 123, 456, new object() });


            var obj11 = ActivatorEx.CreateInstance<ITestActivatorEx>(type);
            var obj12 = ActivatorEx.CreateInstance<ITestActivatorEx>(type, new object[] { });
            var obj13 = ActivatorEx.CreateInstance<ITestActivatorEx>(type, new object[] { 123, null, null });
            //var obj14 = ActivatorEx.CreateInstance<ITestActivatorEx>(type, new object[] { null, 123, null });
            var obj15 = ActivatorEx.CreateInstance<ITestActivatorEx>(type, new object[] { 123, 456, new object() });


            var obj21 = ActivatorEx.CreateInstance<object>(type);
            var obj22 = ActivatorEx.CreateInstance<object>(type, new object[] { });
            var obj23 = ActivatorEx.CreateInstance<object>(type, new object[] { 123, null, null });
            //var obj24 = ActivatorEx.CreateInstance<object>(type, new object[] { null, 123, null });
            var obj25 = ActivatorEx.CreateInstance<object>(type, new object[] { 123, 456, new object() });

        }
    }

    internal interface ITestActivatorEx
    {
        void SetValue(int value);
    }
}
